// 使用装饰器工厂控制延迟时间
const delayDecorator = (times: number): MethodDecorator =>

  // return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
  //   const method = descriptor.value

  //   descriptor.value = () => {
  //     setTimeout(method, times)
  //   }
  // }
  // 简写
  (...args: any[]) => {
    const [, , descriptor] = args
    const method = descriptor.value

    descriptor.value = () => {
      setTimeout(method, times)
    }
  }

class Demo {
  @delayDecorator(1000)
  public response() {
    console.log('delay message');
  }
}

new Demo().response()

